#pragma once
#include <iostream>
#include <string>

class Task
{
private:
	void Run()
	{
		switch (_op)
		{
		case '+':
			_result = _x + _y;
			break;
		case '-':
			_result = _x - _y;
			break;
		case '*':
			_result = _x * _y;
			break;
		case '/':
			if (_y == 0){
				perror("Warning: div zero!");
				_result = -1;
			}
			else{
				_result = _x / _y;
			}
			break;
		case '%':
			if (_y == 0){
				perror("Warning: mod zero!");
				_result = -1;
			}
			else{
				_result = _x % _y;
			}
			break;
		default:
			std::cout << "error operation!" << std::endl;
			break;
		}
	}
public:
	Task(int x = 0, int y = 0, char op = '+')
		: _x(x), _y(y), _op(op)
	{}
	void operator()()
	{
		Run();
	}

	std::string DebugToString()
	{
		return std::to_string(_x) + _op + std::to_string(_y) + " = ?";
	}

	std::string ResultToString()
	{
		return std::to_string(_x) + _op + std::to_string(_y) + " = " + std::to_string(_result);
	}
	~Task()
	{}
	
private:
	int _x;
	int _y;
	char _op;
	int _result;
};
